<#include "../../select.ftl" />
<!DOCTYPE html>
<html>
<head>
<title>维护页面</title>
<script type="text/javascript">
function popAddOrModify(id) {
    var data = {};
    var url = '${absoluteContextPath}/xc/xcGsgj';
    if (id != undefined) {
        data.id = id;
        url = url + "/goEdit";
    } else {
        url = url + "/goAdd";
    }
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal');
                pop_div.html(data.content.data);
                pop_div.modal('show');
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}
function popAddGjjl(id) {
    var data = {};
    var url = '${absoluteContextPath}/xc/xcGjjl';
    data.id = id;
    url = url + "/goAdd";
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal');
                pop_div.html(data.content.data);
                pop_div.modal('show');
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}
function deleteXcGsgj() {
    var i = 0;
    $("input[name=ids]").each(function () {
        if ($(this).prop("checked")) {
            i++;
        }
    });
    if (i == 0) {
        $.showMessage({parentId: "showMessage", message: "请选择您要删除的记录！", type: "success"});
        return false;
    } else {
        $.confirm({
            confirm: function () {
                var values = "";
                $("input[name=ids]").each(function () {
                    if ($(this).prop("checked")) {
                        values += $(this).val() + ",";
                    }
                });
                $("#confirmModal").modal("hide");
                $.post("${absoluteContextPath}/xc/xcGsgj/delete", {
                    'ids': values
                }, function (data) {
                    data = JSON.parse(data);
                    if (data.returnCode == 1) {
                        $.showMessage({parentId: "showMessage", message: "数据删除成功！", type: "success"});
                        refreshTable();
                    } else {
                        $.showMessage({parentId: "showMessage", message: "数据删除异常！", type: "error"});
                    }
                });
            }
        });
    }
}

function refreshTable() {
    $("input[name=currentPage]").val(1);
    $("#search_xcGsgj_table").ajaxSubmit({
        url: '${absoluteContextPath}/xc/xcGsgj/ajaxList',
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                $("#tableContent").html(data.content.data);
            } else {
                $.showMessage({parentId: "showMessage", message: "表格数据加载异常！", type: "success"});
            }
        }
    });
}


function popBathAddOrModify() {
    var i = 0;
    $("input[name=ids]").each(function () {
        if ($(this).prop("checked")) {
            i++;
        }
    });
    if (i == 0) {
        $.showMessage({parentId: "showMessage", message: "请选择您要分配的记录！", type: "success"});
        return false;
    } else {
        var values = "";
        $("input[name=ids]").each(function () {
            if ($(this).prop("checked")) {
                values += $(this).val() + ",";
            }
        });
        $.post("${absoluteContextPath}/xc/xcGsgj/deletes", {
            'ids': values
        }, function (data) {
            data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal');
                pop_div.html(data.content.data);
                pop_div.modal('show');
            } else {
                $.showMessage({parentId: "showMessage", message: "数据删除异常！", type: "error"});
            }
        });
    }
}
//选择分管人
function doSelctReferralsUser(target) {
    var usingOrgId = $("#orgId").val();
    var data = {};
    var url = '${absoluteContextPath}/system/user';
    url = url + "/goSelectSaleUser";
    data.usingOrgId = usingOrgId;
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal2');
                pop_div.html(data.content.data);
                pop_div.modal('show');
                $(pop_div).find("#confirm").click(function () {
                    var id = $("#selectUserId").val();
                    var name = $("#selectUserName").val();
                    $(target).parent().find("input[name=userNameFg]").val(id);
                    $(target).parent().find("input[name=userName]").val(name);
                    $('#myModal2').modal("hide");
                });
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}

//第二次跟进
function doTwoFollowUser(target) {
    var usingOrgId = $("#orgId").val();
    var data = {};
    var url = '${absoluteContextPath}/system/user';
    url = url + "/goSelectSaleUser";
    data.usingOrgId = usingOrgId;
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal2');
                pop_div.html(data.content.data);
                pop_div.modal('show');
                $(pop_div).find("#confirm").click(function () {
                    var id = $("#selectUserId").val();
                    var name = $("#selectUserName").val();
                    $(target).parent().find("input[name=twoFollowId]").val(id);
                    $(target).parent().find("input[name=twoFollow]").val(name);
                    $('#myModal2').modal("hide");
                });
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}
//选择讲解医生
function doSelctDoctor(target) {
    var usingOrgId = $("#orgId").val();
    var data = {};
    var url = '${absoluteContextPath}/system/user';
    url = url + "/goSelectSaleUser";
    data.usingOrgId = usingOrgId;
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal2');
                pop_div.html(data.content.data);
                pop_div.modal('show');
                $(pop_div).find("#confirm").click(function () {
                    var id = $("#selectUserId").val();
                    var name = $("#selectUserName").val();
                    $(target).parent().find("input[name=doctorId]").val(id);
                    $(target).parent().find("input[name=doctorName]").val(name);
                    $('#myModal2').modal("hide");
                });
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}
//选择第二次讲解医生
function doSelctTwoDoctor(target) {
    var usingOrgId = $("#orgId").val();
    var data = {};
    var url = '${absoluteContextPath}/system/user';
    url = url + "/goSelectSaleUser";
    data.usingOrgId = usingOrgId;
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
                var pop_div = $('#myModal2');
                pop_div.html(data.content.data);
                pop_div.modal('show');
                $(pop_div).find("#confirm").click(function () {
                    var id = $("#selectUserId").val();
                    var name = $("#selectUserName").val();
                    $(target).parent().find("input[name=twoDoctorId]").val(id);
                    $(target).parent().find("input[name=twoDoctorName]").val(name);
                    $('#myModal2').modal("hide");
                });
            } else {
                $.showMessage({parentId: "showMessage", message: "数据加载异常！", type: "success"});
            }
        }
    });
}
$(function () {
    $("input[name=ZDate]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })

    $("input[name=tjEnd]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })
    $("input[name=gxDate]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })
    $("input[name=gxEnd]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })
    $("input[name=nextTjDate]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })
    $("input[name=nextTjDateEnd]").focus(function () {
        WdatePicker({dateFmt: 'yyyy-MM-dd'});
    })
    $("div[class='tooltip fade top in']").hide();
});


//        导入
$(function () {
    $("#importCustBtn").click(function () {
        $("#custUploadForm input[type=file]").click();
    });

    $("#custUploadForm input[name=file]").live("change", function () {
        $("#custUploadForm").ajaxSubmit({
            success: function (data) {
                importCustSuccess(data);
            }
        });
    });
});
function importCustSuccess(data) {
    var result = JSON.parse(data);
    if (result.returnCode == 1) {
        var url = "${absoluteContextPath}/xc/xcGsgj/importGsgj";
        var path = result.content;
        $.ajax({
            url: url,
            type: 'post',
            data: {path: path},
            success: function (msg) {
                refreshTable();
                msg = JSON.parse(msg);
                var pop_div = $('#errorMessage');
                var message = "";
                var texts = {};
                texts = msg.returnMsg.split("!");
                for (var r = 0; r < texts.length; r++) {
                    if (r < texts.length - 1) {
                        message += (texts[r] + "!<br>");
                    } else {
                        message += (texts[r]);
                    }
                }
                $("#info").html(message);
                pop_div.modal('show');
                $("input[name=file]").val(null);

            }
        });
    } else {
        $.showMessage({parentId: "showMessage", message: "<strong>错误信息</strong>：" + result.returnMsg, type: "error"});
    }
}
function doDownLoadTemplate() {
    $("#Form_Download").submit();
}
function gsgjCheck() {
    var data = {};
    var ZDate = $("input[id='gxDate']").val();
    var gxEnd = $("input[id='gxEnd']").val();
    var url = '${absoluteContextPath}/xc/xcGsgj';
    if (ZDate != '' && gxEnd !='') {
     data.ZDate = ZDate;
     data.gxEnd = gxEnd;
    url = url + "/goCheck";}
    else{
        $.showMessage({parentId: "showMessage", message: "更新开始日期和结束日期不能为空！", type: "error"});
    }
    $.ajax({
        url: url,
        type: 'post',
        data: data,
        success: function (data) {
            var data = JSON.parse(data);
            if (data.returnCode == 1) {
//                   console.info(data);
                refreshTable();

            } else {
                $.showMessage({parentId: "showMessage", message: data.returnMsg, type: "success"});
            }
        }
    });
}
function popExportExcel() {
    $("#search_xcGsgj_table").attr('action', '${absoluteContextPath}/xc/xcGsgj/export');
    $("#search_xcGsgj_table").submit();
    $("#search_xcGsgj_table").attr('action', '${absoluteContextPath}/xc/xcGsgj/list');
}
</script>
</head>
<body>

<div class="breadcrumbs">
    <ol class="breadcrumb">
        <li><a href="${absoluteContextPath}/home"><i class="fa fa-home"></i>首页</a></li>
        <li><a href="#">现场</a></li>
        <li class="active">高筛跟进</li>
    </ol>
</div>

<div class="main">
    <!-- row -->
    <div class="row">
        <div class="col-md-12">
            <section class="tile">
                <!-- tile body -->
                <div class="tile-body">
                    <div id="showMessage"><#include "../../message.ftl" /></div>
                    <div class="form-horizontal">
                        <form id="search_xcGsgj_table" action="${absoluteContextPath}/xc/xcGsgj/list" method="post">
                        <#--<input type="hidden" name="pageSize" value="${xcGsgjsTable.page.pageSize}"/>-->
                            <input type="hidden" name="currentPage" value="${xcGsgjsTable.page.currentPage}"/>


                            <div class="row">

                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">体检ID</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="spareB" value="${xcGsgjParams.spareB!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">总检日期</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="ZDate" value="${xcGsgjParams.ZDate!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">----</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="tjEnd" value="${xcGsgjParams.tjEnd!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">部门</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="spareE" value="${xcGsgjParams.spareE!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">卡号</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="cardNo" value="${xcGsgjParams.cardNo!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">客户姓名</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="customerName"
                                               value="${xcGsgjParams.customerName!''}" placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">联系电话</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="phone" value="${xcGsgjParams.phone!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                               <#-- <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">单位</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="spareA" value="${xcGsgjParams.spareA!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>-->
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">是否促成</label>

                                    <div class="col-sm-8">
                                    <@select name="whether" value="${xcGsgjParams.whether!''}" list=whetherList class="form-control"/>
                                        <#--<input class="form-control" name="whether" value="${xcGsgjParams.whether!''}" placeholder="" type="text">-->
                                    </div>
                                </div>
                            </div>

                            <div class="row">

                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">一次跟进人</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="userName" value="${xcGsgjParams.userName!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">一次讲解医生</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="doctorName" value="${xcGsgjParams.doctorName!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>

                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">是否回访</label>

                                    <div class="col-sm-8">
                                    <@select name="spareD" value="${xcGsgjParams.spareD!''}" list=whetherList class="form-control"/>
                                        <#--<input class="form-control" name="whether" value="${xcGsgjParams.whether!''}" placeholder="" type="text">-->
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">是否会员</label>

                                    <div class="col-sm-8">
                                    <@select name="spareF" value="${xcGsgjParams.spareF!''}" list=whetherList class="form-control"/>
                                        <#--<input class="form-control" name="whether" value="${xcGsgjParams.whether!''}" placeholder="" type="text">-->
                                    </div>
                                </div>


                            </div>

                            <div class="row">


                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">二次跟进人</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="twoFollow" value="${xcGsgjParams.twoFollow!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">二次讲解医生</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="twoDoctorName" value="${xcGsgjParams.twoDoctorName!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">下次跟进日期</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="nextTjDate" value="${xcGsgjParams.nextTjDate!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">----</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="nextTjDateEnd" value="${xcGsgjParams.nextTjDateEnd!''}"
                                               placeholder="" type="text">
                                    </div>
                                </div>

                                <div class="form-group col-md-3">
                                    <label class="col-sm-4 control-label" for="exampleInputEmail2">显示条数:</label>

                                    <div class="col-sm-8">
                                        <input class="form-control" name="pageSize"
                                               value="${xcGsgjsTable.page.pageSize}" placeholder="" type="text"/>
                                    </div>
                                </div>
                                <div class="form-group col-md-3">
                                    <label class="col-sm-4"></label>

                                    <div class="col-sm-8">
                                        <button type="button" class="btn btn-primary" onclick="refreshTable()">查询
                                        </button>
                                        <button type="reset" class="btn btn-default">重置</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </section>
            <section class="tile">
                <div class="tile-header">

                    <h1 style="color:red ; font-size:18px">
                        <button type="button" class="btn btn-green" onclick="popAddOrModify();"><i
                                class="fa fa-plus"></i><span class="margin-left-5">新增</span></button>
                        <button type="button" class="btn btn-cyan" onclick="deleteXcGsgj();"><i
                                class="fa fa-trash-o"></i><span class="margin-left-5">删除</span></button>
                        <button type="button" class="btn btn-red" onclick="popBathAddOrModify();"><i
                                class="fa fa-plus"></i><span class="margin-left-5">批量分配</span></button>
                        <button id="importCustBtn" type="button" class="btn btn-cyan"><i
                                class="fa fa-arrow-circle-o-down"></i><span class="margin-left-5">导入模板</span>
                        </button>
                        <button type="button" class="btn  btn-primary" onclick="doDownLoadTemplate();"><i
                                class="fa fa-download"></i><span class="margin-left-5">导入模板下载</span></button>
                        <button type="button" class="btn btn-green" onclick="popExportExcel();"><i
                                class="fa fa-plus"></i><span class="margin-left-5">导出</span></button>
                        &nbsp;&nbsp;更新日期: <input id="gxDate" name="gxDate" value=""  placeholder="" type="text">
                        ----&nbsp;&nbsp;<input id="gxEnd" name="gxEnd" value=""
                                               placeholder="" type="text">

                        &nbsp;&nbsp;    <button type="button" class="btn btn-red" onclick="gsgjCheck()">更新
                        </button>
                    </h1>


                </div>
                <div class="tile-body nopadding">
                    <div class="table-responsive" id="tableContent">
                    <#include "table.ftl"/>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>
    <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    </div>
    <div class="modal fade" id="selectIllIndexModal" tabindex="-1" role="dialog"
         aria-labelledby="selectIllIndexModalLabel" aria-hidden="true"></div>
    <form id="Form_Download" action="${absoluteContextPath}/xc/xcGsgj/downloadTemplate" method="post"
          style="display: none">
        <input name="serverFileName" type="hidden" value="GsgjDownload.xlsx"/>
        <!-- 下载潜在客户导入模板 -->
        <input name="clientFileName" type="hidden" value="高筛跟进导入模板.xlsx"/>
        <!-- 下载潜在客户导入模板 -->
    </form>
    <form id="custUploadForm" method="post" enctype="multipart/form-data"
          action="${absoluteContextPath}/upload/ajax" style="display: none">
        <input type="file" name="file"/>
        <input type="text" name="fileType" value="xlsx">
    </form>
    <div class="modal fade" id="errorMessage" tabindex="-1" role="dialog" aria-labelledby="cardCode04"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">导入提示</h4>
                </div>
                <div class="modal-body">
                    <div id="info"></div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
    </div>

</div>
</body>
</html>
